import React, { useState,useEffect } from "react";



function App() {
  const [Tv,setTv] = useState([
    {id:'001',TvName:'仙剑奇侠传1'},
    {id:'002',TvName:'仙剑奇侠传3'},
    {id:'003',TvName:'恶作剧之吻'},
    {id:'004',TvName:'就想爱着你'},
  ])

   const setTvhandle = ()=>{
    setTv([...Tv,{id:Date.now(),TvName:'xxxx'}])
   }
   useEffect(()=>{
    console.log('成员添加成功');
   },[Tv])
 return (
  <div>
    <h1>最受观众喜爱电视剧排行榜</h1>
    <hr />
    <button onClick = {setTvhandle}>添加电视剧</button>
    <ul>
      {Tv.map(item=>{
        return(
          <li key={item.id}>{item.TvName}</li>
        )
      })}
    </ul>
  </div>
 )
}

export default App;
